/*
 * MIT License
 * 
 * Copyright (c) 2017 wen.gu <454727014@qq.com>
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

/*****************************************************************************
 * Name:general_error.h
 *
 * Purpose: standard header,and unified error type define
 *
 * Note: 'G' in macro and data type indicate 'general'
 *     
 * Version: 0.1
 *
 * Developer:
       wen.gu, 2016-06-23
 * Modified by:
 * 
 *
 *****************************************************************************/


#ifndef __GENERAL_ERROR_H__
#define __GENERAL_ERROR_H__

#include "cbus/core/cbus_type.h"

/***************************************************************************
 *
 * macro declaration
 *
 ***************************************************************************/

/***************************************************************************
 *
 * data structure declaration
 *
 ***************************************************************************/
/** 
 * The general_error_t enumeration defines the standard Errors.    
 * These errors should cover most of the common failure cases.  However,  
 * vendors are free to add additional error messages of their own as  
 * long as they follow these rules: 
 *
 *  1. Vendor error messages shall be in the range of 0x90000000 to 0x9000FFFF. 
 *
 *  2. Vendor error messages shall be defined in a header file provided 
 *     with the plugin/component/module/library.  No error messages are allowed
 *     that are not defined. 
 */
typedef enum general_error_e
{
    G_OK = 0,
    G_FAIL = -1,
    G_ErrNone = G_OK,
    /** There were insufficient resources to perform the requested operation */  
    G_ErrInsufficientResources = (GS32) 0x80001000,  
    /** There was an error, but the cause of the error could not be determined */  
    G_ErrUndefined = (GS32) 0x80001001,

    /** The name string was invalid */
    G_ErrInvalidName = (GS32)0x80001002,
    /** No target with the specified name string was found */
    G_ErrNotFound = (GS32)0x80001003,
    /** One or more parameters were not valid */
    G_ErrBadParameter = (GS32)0x80001004,
    /** The requested function is not implemented */
    G_ErrNotImplemented = (GS32)0x80001005,
    /** The buffer was emptied before the next buffer was ready */
    G_ErrUnderflow = (GS32)0x80001006,
    /** The buffer was not available when it was needed */
    G_ErrOverflow = (GS32)0x80001007,
    /** The hardware failed to respond as expected */
    G_ErrHardware = (GS32)0x80001008,
    /** havn't enough free memory in buffer */
    G_ErrNoMemory = (GS32)0x80001009,
    /** some excecption about out of range */
    G_ErrOutOfRange = (GS32)0x8000100A,


    /** No more indicies can be enumerated */
    G_ErrNoMore = (GS32)0x8000100E,
    /** The target detected a version mismatch */
    G_ErrVersionMismatch = (GS32)0x8000100F,
    /** The component is not ready to return data at this time */
    G_ErrNotReady = (GS32)0x80001010,
    /** There was a timeout that occurred */
    G_ErrTimeout = (GS32)0x80001011,
	/** this operation would block */
	G_ErrWouldBlock = (GS32)0x80001012,

    /** need more data */
    G_ErrNeedMoreData = (GS32)0x80001016,
    /** doesn't initialized */
    G_ErrNoInit = (GS32)0x80001017,

    /** The values encapsulated in the parameter or config structure are not supported. */
    G_ErrUnsupportedCommand = (GS32)0x80001019,
    /** The parameter or config indicated by the given index is not supported. */
    G_ErrUnsupportedInvokeId = (GS32)0x8000101A,

    /** EOF  error */
    G_ErrEOF = (GS32)0x8000101B,
    G_ErrInvalidOperation = (GS32)0x8000101C, /** invalid operation */
    G_ErrInvalidStatus = (GS32)0x8000101D,  /** invalid status */
    G_ErrDisconnected  = (GS32)0x8000101E, /** the connection is disconnected between client and service */
    G_ErrNoSubscriber  = (GS32)0x8000101F, /** a event have not subscriber when it notify */
    G_ErrAlreadyExist  = (GS32)0x80001020, /** something already exist */
    G_ErrUnsupportedType = (GS32)0x80001021, /** unsupported type */
    G_ErrInterrupted     = (GS32)0x80001022, /** worker flow was interrupted by something(e.g signal, like: EINTR) */

    /** Reserved region for introducing general Standard Extensions */
    G_ErrExtensions = (GS32)0x8F000000, 
    /** Reserved region for introducing Vendor Extensions */
    G_ErrStartUnused = (GS32)0x90000000, 
    G_ErrMax = 0x7fffffff   
}GErrc;  /** general error code */

/***************************************************************************
 *
 * API declaration
 *
 ***************************************************************************/



#endif //end of __GENERAL_ERROR_H__
 
